<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>

<body>

</body>
<script>
    hd = {
        name: 'tom',
        age: 11
    }

    // 快速的复制方法
    let w = Object.assign({}, hd)
    console.log(w);

    let t = { ...hd }
    console.log(t)

    // 深拷贝

    let obj = {
        name: "test",
        user: {
            name: "hdcms"
        }
    }

    let a = {
        name: 'test',
        title: 'ccc'
    }
    console.log(JSON.stringify(Object.entries(a), null, 2))

    function copy(obj) {
        let res = obj instanceof Array ? [] : {};
        for (const [k, v] of Object.entries(obj)) {
            res[k] = typeof v == "object" ? copy(v) : v;

        }
        return res;
    }


</script>

</html>